/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andrés Felipe
 */
@Entity
@Table(name = "\"javeriana.sc.cc\".\"t_customerRequest\"")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CustomerRequest.findAll", query = "SELECT c FROM CustomerRequest c"),
    @NamedQuery(name = "CustomerRequest.findByIdrequest", query = "SELECT c FROM CustomerRequest c WHERE c.idrequest = :idrequest"),
    @NamedQuery(name = "CustomerRequest.findByCreationdate", query = "SELECT c FROM CustomerRequest c WHERE c.creationdate = :creationdate"),
    @NamedQuery(name = "CustomerRequest.findIdRequest", query = "SELECT c FROM CustomerRequest c WHERE c.creationdate = :creationdate AND c.customeridentification.customerPK.identification = :customerIdentification AND c.customeridentification.customerPK.pymeidentification = :pymeIdentification")})
public class CustomerRequest implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idrequest")
    private Integer idrequest;
    @Basic(optional = false)
    @NotNull
    @Column(name = "creationdate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationdate;
    @OneToMany(cascade = CascadeType.REMOVE, mappedBy = "customerRequest")
    private List<RequestXproduct> requestXproductList;
    @JoinColumns({
        @JoinColumn(name = "customeridentification", referencedColumnName = "identification"),
        @JoinColumn(name = "pymeidentification", referencedColumnName = "pymeidentification")})
    @ManyToOne(optional = false,cascade = CascadeType.REMOVE)
    private Customer customeridentification;
   

    public CustomerRequest() {
    
    }

    public CustomerRequest(Integer idrequest) {
        this.idrequest = idrequest;
        
    }

    public CustomerRequest(Integer idrequest, Date creationdate) {
        this.idrequest = idrequest;
        this.creationdate = creationdate;
        
    }

  
    public Integer getIdrequest() {
        return idrequest;
    }

    public void setIdrequest(Integer idrequest) {
        this.idrequest = idrequest;
    }

    public Date getCreationdate() {
        return creationdate;
    }

    public void setCreationdate(Date creationdate) {
        this.creationdate = creationdate;
    }

    @XmlTransient
    public List<RequestXproduct> getRequestXproductList() {
        return requestXproductList;
    }

    public void setRequestXproductList(List<RequestXproduct> requestXproductList) {
        this.requestXproductList = requestXproductList;
    }

    public Customer getCustomeridentification() {
        return customeridentification;
    }

    public void setCustomeridentification(Customer customeridentification) {
        this.customeridentification = customeridentification;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idrequest != null ? idrequest.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CustomerRequest)) {
            return false;
        }
        CustomerRequest other = (CustomerRequest) object;
        if ((this.idrequest == null && other.idrequest != null) || (this.idrequest != null && !this.idrequest.equals(other.idrequest))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CustomerRequest[ idrequest=" + idrequest + " ]";
    }
    
}
